package org.srtc.infopub.application.http.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.srtc.infopub.application.dacc.MonitorInfoService;
import org.srtc.infopub.application.dacc.imp.MonitorInfoServiceImp;


/**
 * 该servlet负责根据查询字符串返回text格式的查询结果。
 * 
 * @author blackcat
 * 
 */
@SuppressWarnings("serial")
public class HttpQueryService extends HttpServlet {

	MonitorInfoService monitorInfoService = new MonitorInfoServiceImp();

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		String queryStr;
		// String nodeId;
		String result;

		response.setContentType("text/html;charset=utf-8");
		response.setStatus(HttpServletResponse.SC_OK);
		PrintWriter writer = response.getWriter();

		queryStr = request.getParameter("qStr");
		// nodeId = request.getParameter("nodeId");

		if (null != queryStr) {
			result = monitorInfoService.queryInfo(queryStr);
			writer.println(result);

		}
	}
}
